package net.mingsoft.base.util;

import java.util.*;
import freemarker.core.*;
import freemarker.cache.*;
import java.io.*;
import freemarker.template.*;

public class FtlUtil
{
    public static String rendering(final Map root, final String content) {
        final Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
        final StringTemplateLoader stringLoader = new StringTemplateLoader();
        stringLoader.putTemplate("template", content);
        cfg.setNewBuiltinClassResolver(TemplateClassResolver.ALLOWS_NOTHING_RESOLVER);
        cfg.setNumberFormat("#");
        cfg.setTemplateLoader((TemplateLoader)stringLoader);
        Template template = null;
        try {
            template = cfg.getTemplate("template", "utf-8");
            final StringWriter writer = new StringWriter();
            template.process((Object)root, (Writer)writer);
            return writer.toString();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        catch (TemplateException e2) {
            e2.printStackTrace();
        }
        return content;
    }
}
